<?php
 /******************************************************************************
 *   GunCMS is an avid supporter of open source software. This is the appropriate 
 *   option if you are creating an open source application with a license 
 *   compatible with the GNU GPL license v3.
 *   For details http://www.gnu.org/licenses/gpl.html
 *   DO NOT USE FOR COMMERCIAL WITHOUT PERMISSION
 *
 * GunCMS Version 1.0.3
 * Copyright(c) 2009-2010, T & L GdbR
 * info@guncms.de
 * 
 * http://www.guncms.de
 ********************************************************************************/
class BWebshopSettingsBean {

	public function __construct() {
 	}
 	
 	public static function get_all_settings($db) {
		$strSQL = sprintf("SELECT * FROM ".TBL_SHOP_SETTINGS);
		$res = $db->get_results($strSQL);		
		$out = array();
		foreach ($res as $item) {
			$out[$item->settings_key] = $item->settings_value;
		}
		return $out;
	}
	
	/*	webshop settings, corresponding to a single key
	 * the returned value is a single string
	 */
	public static function get_setting_by_key($db, $key) {
		$strSQL = sprintf("SELECT settings_value FROM ".TBL_SHOP_SETTINGS." WHERE settings_key = '$key'");
		return $db->get_var($strSQL);
	}
	
	public static function update_all_settings($db, $list) {
		foreach ($list as $key => $value) {
			$strSQL = sprintf("UPDATE ".TBL_SHOP_SETTINGS." SET settings_value = '$value' WHERE settings_key = '$key'");
			$db->query($strSQL);
		}
	}
	
}
?>
